<?php

use common\helpers\Url;
use yii\helpers\Html;

$this->title = '企业统计';
$this->params['breadcrumbs'][] = ['label' => $this->title];
?>

<style>
    .info-box-number {
        font-size: 20px;
    }
</style>

<div class="row">
    <div class="col-md-2 col-sm-6 col-xs-12">
        <div class="info-box">
            <div class="info-box-content p-md">
                <span class="info-box-number"><i class="icon ion-person-stalker blue"></i> <?= $merchantCount ?></span>
                <span class="info-box-text">企业数(个)</span>
            </div>
            <!-- /.info-box-content -->
        </div>
        <!-- /.info-box -->
    </div>
    <div class="col-md-2 col-sm-6 col-xs-12">
        <div class="info-box">
            <div class="info-box-content p-md">
                <span class="info-box-number"><i class="icon ion-stats-bars red"></i> <?= $merchantTotalMoney ?></span>
                <span class="info-box-text">企业今日金额(元)</span>
            </div>
            <!-- /.info-box-content -->
        </div>
        <!-- /.info-box -->
    </div>
    <div class="col-md-2 col-sm-6 col-xs-12">
        <div class="info-box">
            <div class="info-box-content p-md">
                <span class="info-box-number"><i class="icon ion-card green"></i> <?= $merchantAccount['user_money'] ?? 0 ?></span>
                <span class="info-box-text">企业剩余余额(元)</span>
            </div>
            <!-- /.info-box-content -->
        </div>
        <!-- /.info-box -->
    </div>
    <div class="col-md-2 col-sm-6 col-xs-12">
        <div class="info-box">
            <div class="info-box-content p-md">
                <span class="info-box-number"><i class="icon ion-arrow-graph-up-right yellow"></i> <?= $merchantAccount['accumulate_money'] ?? 0 ?></span>
                <span class="info-box-text">企业累计余额(元)</span>
            </div>
            <!-- /.info-box-content -->
        </div>
        <!-- /.info-box -->
    </div>
    <div class="col-md-4 col-sm-6 col-xs-12">
        <div class="info-box">
            <div class="info-box-content p-md">
                <span class="info-box-number"><i class="icon ion-ios-pulse red"></i> <?= $merchantAccount['accumulate_money'] - $merchantAccount['user_money'] ?></span>
                <span class="info-box-text">企业累计提现(元)</span>
            </div>
            <!-- /.info-box-content -->
        </div>
        <!-- /.info-box -->
    </div>
</div>

<div class="row shop-index">
    <div class="col-md-6 col-xs-12">
        <div class="box box-solid">
            <div class="box-header">
                <i class="fa fa-circle blue" style="font-size: 8px"></i>
                <h3 class="box-title">待处理</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
                <div class="row">
                    <div class="col-xs-6 col-md-6 text-center">
                        <span class="info-box-number blue"><?= $merchantApplyCount; ?></span>
                        <div class="knob-label">企业申请</div>
                    </div>
                    <div class="col-xs-6 col-md-6 text-center">
                        <span class="info-box-number blue"><?= $merchantCommissionWithdraw ?></span>
                        <div class="knob-label">提现申请</div>
                    </div>
                    <!-- ./col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.box-body -->
        </div>
        <!-- /.box -->
    </div>
    <div class="col-md-6 col-xs-12">
        <div class="box box-solid" style="padding-bottom: 20px">
            <div class="box-header">
                <i class="fa fa-circle blue" style="font-size: 8px;"></i>
                <h3 class="box-title">数据来源</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
                <?= Html::dropDownList('merchant', $merchant_id, $merchant, [
                    'class' => 'form-control',
                    'id' => 'merchant_id'
                ])?>            <!-- /.row -->
            </div>
            <!-- /.box-body -->
        </div>
        <!-- /.box -->
    </div>
</div>

<div class="row">
    <div class="col-md-6 col-xs-12">
        <div class="box box-solid">
            <div class="box-header">
                <i class="fa fa-circle blue" style="font-size: 8px"></i>
                <h3 class="box-title">收入统计</h3>
            </div>
            <?= \common\widgets\echarts\Echarts::widget([
                'config' => [
                    'server' => Url::to(['earnings', 'merchant_id' => $merchant_id]),
                    'height' => '315px'
                ]
            ]) ?>
            <!-- /.box-body -->
        </div>
        <!-- /.box -->
    </div>
    <div class="col-md-6 col-xs-12">
        <div class="box box-solid">
            <div class="box-header">
                <i class="fa fa-circle blue" style="font-size: 8px"></i>
                <h3 class="box-title">支出统计</h3>
            </div>
            <?= \common\widgets\echarts\Echarts::widget([
                'config' => [
                    'server' => Url::to(['withdraw', 'merchant_id' => $merchant_id]),
                    'height' => '315px'
                ]
            ]) ?>
            <!-- /.box-body -->
        </div>
        <!-- /.box -->
    </div>
</div>

<script>
    $('#merchant_id').change(function () {
        var val = $(this).val();
        location.href = '<?= Url::to(["index"])?>' + "?merchant_id="+val;
    })
</script>